package vcp.client.reports;

import java.io.Serializable;

import org.joda.time.format.DateTimeFormat;

import vcp.entity.Lot;
import vcp.enums.ReportType;
/**
 * 
 * @author VCP team
 *<p> non working lots report class </p>
 */
public class NonWorkingLotsReport extends ReportAbstract
{

	/**
	 * 
	 */
	private static final long serialVersionUID = - 8041101122522654620L;

	/**
	 * Non working lots report constructor
	 */
	public NonWorkingLotsReport ()
	{
		super(ReportType.NON_WORKING_LOT);
	}

	// ****************************************************************************************************************************
	// Public methods
	// ****************************************************************************************************************************
	/**
	 * add lot to report
	 * @param lot
	 */
	public void add ( Lot lot )
	{
		NonWorkingLostRowWrapper nonWorkingLostRowWrapper = new NonWorkingLostRowWrapper();

		nonWorkingLostRowWrapper.setSiteName(lot.getParentSite().getSiteName());
		nonWorkingLostRowWrapper.setFloor(lot.getFloor());
		nonWorkingLostRowWrapper.setRow(lot.getRow());
		nonWorkingLostRowWrapper.setColumn(lot.getColumn());
		nonWorkingLostRowWrapper.setBrokenStartDate(DateTimeFormat.forPattern("dd/MM/YYYY").print(lot.getBrokeStartDate()));
		nonWorkingLostRowWrapper.setBrokenEndDate(DateTimeFormat.forPattern("dd/MM/YYYY").print(lot.getBrokeEndDate()));

		this.reportDataRow.add(nonWorkingLostRowWrapper);
	}

	// ****************************************************************************************************************************
	// ReportAbstract methods
	// ****************************************************************************************************************************
	@Override
	public String[] getHeaders ()
	{
		return new String[]
				{ "Site Name",
				"Floor",
				"Row",
				"Column",
				"Start Date",
				"End Date" };
	}

	// ****************************************************************************************************************************
	// Private class
	// ****************************************************************************************************************************
	/**
	 * 
	 * @author VCP team
	 *<p>non working row of lots report</p>
	 */
	private class NonWorkingLostRowWrapper implements Serializable, IWrapperConverter
	{
		/**
		 * 
		 */
		private static final long serialVersionUID = - 3370611504058952153L;

		// ****************************************************************************************************************************
		// Setter-Getters methods
		// ****************************************************************************************************************************
		private String brokenEndDate;
		/**
		 * getter
		 * @return end date 
		 */
		public String getBrokenEndDate ()
		{
			return this.brokenEndDate;
		}
		/**
		 * setter
		 * @param brokenEndDate
		 */
		public void setBrokenEndDate ( String brokenEndDate )
		{
			this.brokenEndDate = brokenEndDate;
		}

		private String brokenStartDate;
		/**
		 * getter
		 * @return broken start date
		 */
		public String getBrokenStartDate ()
		{
			return this.brokenStartDate;
		}
		/**
		 * setter
		 * @param brokenStartDate
		 */
		public void setBrokenStartDate ( String brokenStartDate )
		{
			this.brokenStartDate = brokenStartDate;
		}

		private Integer column;
		/**
		 * getter
		 * @return column
		 */
		public Integer getColumn ()
		{
			return this.column;
		}
		/**
		 * setter
		 * @param column
		 */
		public void setColumn ( Integer column )
		{
			this.column = column;
		}

		private Integer row;
		/**
		 * getter
		 * @return row
		 */
		public Integer getRow ()
		{
			return this.row;
		}
		/**
		 * setter
		 * @param row
		 */
		public void setRow ( Integer row )
		{
			this.row = row;
		}

		private Integer floor;
		/**
		 * getter
		 * @return floor
		 */
		public Integer getFloor ()
		{
			return this.floor;
		}
		/**
		 * setter
		 * @param floor
		 */
		public void setFloor ( Integer floor )
		{
			this.floor = floor;
		}

		private String siteName;
		/**
		 * getter
		 * @return site name
		 */
		public String getSiteName ()
		{
			return this.siteName;
		}
		/**
		 * setter
		 * @param siteName
		 */
		public void setSiteName ( String siteName )
		{
			this.siteName = siteName;
		}

		// ****************************************************************************************************************************
		// IWrapperConverter methods
		// ****************************************************************************************************************************
		@Override
		public Object[] toObjectArray ()
		{
			return new Object[]
					{ this.getSiteName()
					, this.getFloor()
					, this.getRow()
					, this.getColumn()
					, this.getBrokenStartDate()
					, this.getBrokenEndDate() };
		}
	}
}
